package com.lbloca.locate.ui.fragment;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;
import com.lbloca.locate.R;
import com.lbloca.locate.biz.AppBiz;
import com.lbloca.locate.biz.UserBiz;
import com.lbloca.locate.ui.activity.BindMobileActivity;
import com.lbloca.locate.ui.activity.EmptyActivity;
import com.lbloca.locate.ui.activity.ServiceActivity;
import com.lbloca.locate.ui.activity.SettingActivity;
import com.lbloca.locate.ui.activity.VipActivity;
import com.lbloca.locate.ui.base.BaseFragment;
import com.lbloca.locate.weight.MeInfoView;

import butterknife.BindView;
import butterknife.OnClick;

public class MeFragment extends BaseFragment {

    @BindView(R.id.linear_items)
    LinearLayout linearItems;
    @BindView(R.id.tv_uid)
    TextView tvUid;

    private final String[] titles = {"查看Ta的位置", "离开/到达地点提醒", "我的轨迹","绑定手机", "在线客服", "设置"};
    private final int[] iconIds = {R.drawable.dingweita, R.drawable.tixing,R.drawable.zuji,R.mipmap.shouji, R.drawable.kefu, R.drawable.shezhi};

    public static final MeFragment getInstance() {
        return new MeFragment();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.frag_me;
    }

    @Override
    protected void initView(View view) {
        for (int i = 0; i < linearItems.getChildCount(); i++) {
            MeInfoView infoView = (MeInfoView) linearItems.getChildAt(i);
            infoView.setViewTitle(titles[i]);
            infoView.setViewIcon(iconIds[i]);
        }
    }

    @Override
    protected void initEvent() {

    }

    @Override
    protected void initData() {

    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        if (!hidden) {
            ImmersionBar.with(this).statusBarAlpha(0f).init();
            tvUid.setText("ID:" + UserBiz.getInstance().getUid());
        }
        super.onHiddenChanged(hidden);
    }

    @OnClick({R.id.item_look_address, R.id.item_address_tx, R.id.item_my_trajectory, R.id.item_service, R.id.item_setting,R.id.tv_sjvip,R.id.item_bind_mobile})
    void onClick(View view) {
        boolean isVip = AppBiz.getInstance().getVipState();
        switch (view.getId()) {
            case R.id.item_look_address:

                if(isVip){
                    EmptyActivity.start(mContext,"查看Ta的位置");
                }else{
                    VipActivity.start(mContext);
                }


                break;
            case  R.id.item_address_tx:
                if(isVip) {
                    EmptyActivity.start(mContext, "地点提醒");
                }else{
                    VipActivity.start(mContext);
                }
                break;
            case R.id.item_bind_mobile:
                BindMobileActivity.start(mContext);
                break;
            case  R.id.item_my_trajectory:

                if(isVip) {
                    EmptyActivity.start(mContext,"我的轨迹");
                }else{
                    VipActivity.start(mContext);
                }
                break;
            case R.id.item_setting:
                SettingActivity.start(mContext);
                break;
            case R.id.tv_sjvip:
                VipActivity.start(mContext);
                break;
            case R.id.item_service:
                ServiceActivity.start(mContext);
                break;
            default:
                break;
        }
    }
}
